Adding forms
Assumed that you already followed Install instructions, follow next steps to add forms to
your app:
- Create a new dialog resource, no border, child
styles, delete Ok and Cancel buttons.
- Arrange the controls you want to use with the table
of your database
- Create the class with ClassWizard deriving the new
form from CFormView.
- Add the OnInitialUpdate() message handler and the following code:(in the
following example you access the fields IdCust and
Name of the
table Customers)
OpenCursor( "SELECT * FROM
[Customers]"); |
AddEditCtrl( IDC_EDIT_ID,
"IdCust", FLAG_EDIT_R_ONLY); |
AddEditCtrl( IDC_EDIT_NAME,
"Name"); |
CDBForm::OnInitialUpdate(); |
- Change the base class of the form from CFormView to CDBForm(see ADBWizard )
- Change the default constructor of the new class of
the form from CFormView to CDBForm(see ADBWizard )
- Change the referring class of the message handler
from CformView to CDBForm
(see ADBWizard )
- Insert a new menu item in the main menu.
- Create the regular handler in the application.
- Make the header file of the new class available to
the application.
- Insert the following code in it (assumed the new
form is CformTest).
OpenForm( RUNTIME_CLASS(CFormTest),
"Title"); |
- Compile and link.
IMPORTANT: follow the previous steps in the
right order or Class Wizard will generate a wrong message
list.